/**
 * Created by PengWei on 2018/7/17.
 */
namespace mengdao {
    export class ObjectHandler {

        private _mather: IMatcher;
        private readonly _handler: Function;

        public constructor(matcher: IMatcher, handler: Function) {
            this._mather = matcher;
            this._handler = handler;
        }

        public handle(object: any): void {
            if (this._mather.matches(object)) {
                this._handler(object);
            }
        }
    }
}